//
//  MoreViewController.m
//  NBTripe
//
//  Created by 陈曦 on 16/1/9.
//  Copyright © 2016年 Vicki. All rights reserved.
//

#import "MoreViewController.h"
#import "VCBigCollectionViewCell.h"
#import "moreModel.h"

@interface MoreViewController ()<UICollectionViewDelegate, UICollectionViewDataSource>

@end

@implementation MoreViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self createCollectionView];
    // Do any additional setup after loading the view.
}

#pragma mark - create CollectionView

- (void)createCollectionView {
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc]init];
    // 滑动方向
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
    
    // item的大小
    flowLayout.itemSize = CGSizeMake((self.view.width - 20) / 2, self.view.width / 2 - 5);
    
    // item的最小行间距
    flowLayout.minimumLineSpacing = 10;
    
    // item的最小列间距
    flowLayout.minimumInteritemSpacing = 10;
    
    flowLayout.sectionInset = UIEdgeInsetsMake(0, 5, 0, 5);

    UICollectionView *collectionView = [[UICollectionView alloc]initWithFrame:CGRectMake(0, 0, self.view.width, self.view.height - 112) collectionViewLayout:flowLayout];
    collectionView.delegate = self;
    collectionView.dataSource = self;
    collectionView.backgroundColor = [UIColor colorWithRed:250/255.0 green:246/255.0 blue:232/255.0 alpha:1];
    [collectionView registerNib:[UINib nibWithNibName:@"VCBigCollectionViewCell" bundle:nil] forCellWithReuseIdentifier:@"VCBigCollectionViewCellIdentifier"];
    [self.view addSubview:collectionView];
    
}

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
    return self.moreModel.datas.count;
}

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
    VCBigCollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"VCBigCollectionViewCellIdentifier" forIndexPath:indexPath];
    cell.dataModel = self.moreModel.datas[indexPath.item];
    
    return cell;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
